package com.programmercarl.array;

import java.util.Scanner;

/**
 * https://kamacoder.com/problempage.php?pid=1070
 *
 * @author yulongtian
 * @create 2024-12-12 17:27
 */
public class Test13 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        arr[0] = sc.nextInt();
        for (int i = 1; i < n; i++) {
            arr[i] = arr[i - 1] + sc.nextInt();
        }
        while (sc.hasNextInt()) {
            int start = sc.nextInt();
            int end = sc.nextInt();
            if (start == 0) {
                System.out.println(arr[end]);
            } else {
                System.out.println(arr[end] - arr[start - 1]);
            }
        }

        sc.close();
    }
}
